#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
const int N = 30;
int st[N], a[N];
int n, r;
void dfs(int x)
{
	if (x > r)
	{
		for (int i = 1; i <= r; i++)
			printf("%3d", a[i]);
		printf("\n");
		return;
	}
	for (int i = 1; i <= n; i++)
	{
		if ((st[i] == 0 && i > a[x - 1]) || x == 1)
		{
			st[i] = 1;
			a[x] = i;
			dfs(x + 1);
			st[i] = 0;
			a[x] = 0;
		}
	}
}
int main()
{
	scanf("%d%d", &n, &r);
	dfs(1);
	return 0;
}